<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>MySQL 管理工具</title>
    
    <!-- Bootstrap CSS -->
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.3/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    
    <style>
        .sidebar {
            height: 100vh;
            background-color: #f8f9fa;
            padding: 20px;
            border-right: 1px solid #dee2e6;
            overflow-y: auto;
            position: fixed;
            width: 250px;
        }
        .main-content {
            margin-left: 250px;
            padding: 20px;
        }
        .database-item, .table-item {
            cursor: pointer;
            padding: 5px;
            border-radius: 4px;
        }
        .database-item:hover, .table-item:hover {
            background-color: #e9ecef;
        }
        .table-item {
            margin-left: 20px;
        }
        .table-item.active {
            background-color: #0d6efd;
            color: white;
        }
        .sql-editor {
            font-family: monospace;
            resize: vertical;
            min-height: 120px;
        }
        .result-container {
            max-height: 400px;
            overflow-y: auto;
        }
        .card {
            margin-bottom: 20px;
            box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
        }
    </style>
</head>
<body>
    <!-- 左侧数据库列表 -->
    <div class="sidebar">
        <h5 class="mb-3">数据库列表</h5>
        <div id="databaseList">
            <!-- 数据库列表将在这里动态生成 -->
        </div>
    </div>
    
    <!-- 右侧主内容区 -->
    <div class="main-content">
        <!-- SQL 执行器 -->
        <div class="card mb-4">
            <div class="card-header d-flex justify-content-between align-items-center">
                <span>SQL 执行器</span>
                <div>
                    <button class="btn btn-primary btn-sm" onclick="executeSql()">
                        <i class="fa fa-play"></i> 执行
                    </button>
                    <button class="btn btn-secondary btn-sm" onclick="clearSql()">
                        <i class="fa fa-trash"></i> 清空
                    </button>
                </div>
            </div>
            <div class="card-body">
                <textarea id="sqlInput" class="form-control sql-editor mb-3" 
                    placeholder="请输入 SQL 语句..."></textarea>
                <div id="sqlResult" class="result-container">
                    <!-- SQL 执行结果将在这里显示 -->
                </div>
            </div>
        </div>

        <!-- 表格数据 -->
        <div class="card">
            <div class="card-header">
                <span id="currentTableTitle">数据列表</span>
            </div>
            <div class="card-body">
                <div id="tableContainer">
                    <!-- 表格数据将在这里显示 -->
                </div>
            </div>
        </div>
    </div>

    <!-- 编辑数据模态框 -->
    <div class="modal fade" id="dataModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">编辑数据</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <form id="dataForm">
                        <!-- 动态生成的表单字段 -->
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="saveData()">保存</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 新增数据模态框 -->
    <div class="modal fade" id="addModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">新增数据</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <form id="addForm">
                        <!-- 动态生成的表单字段 -->
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="saveNewData()">保存</button>
                </div>
            </div>
        </div>
    </div>

    <!-- JavaScript -->
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.3/js/bootstrap.bundle.min.js"></script>
    <script src="/js/main.js"></script>
</body>
</html> 